unit RtcKbmHz;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
  Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Grids,
  Vcl.DBGrids, RzDBGrid, RzPanel, Vcl.ExtCtrls, RzSplit, Data.DB, kbmMemTable,
  kbmMemSQL,rtcCliModule,rtcDB,rtcInfo, DataOperate;

type
  TframRtcKbmHz = class(TFrame)
    rzspltr1: TRzSplitter;
    pnl1: TRzPanel;
    pnl2: TRzPanel;
    RzDBGrid1: TRzDBGrid;
    edtSql: TEdit;
    btn1: TButton;
    edt2: TEdit;
    btn2: TButton;
    btn3: TButton;
    edt3: TEdit;
    kbmMemSQL1: TkbmMemSQL;
    kbmtbl1: TkbmMemTable;
    ds1: TDataSource;
    procedure btn1Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    DataOperateFrm: TDataOperate;
  end;

implementation

{$R *.dfm}

procedure TframRtcKbmHz.btn1Click(Sender: TObject);
var
   tmpData:TRtcDataSet;
begin
  with kbmtbl1 do
  begin
    Close;
    Filtered := false;
    tmpData:=DataOperateFrm.GetRemoteQuery(edtSql.Text);
    RtcDataSetFieldsToDelphi(tmpData, kbmtbl1);
    CreateTable;
    RtcDataSetRowsToDelphi(tmpData, kbmtbl1);
  end;

  ds1.DataSet := kbmtbl1;
end;

procedure TframRtcKbmHz.btn2Click(Sender: TObject);
var
  s: string;
begin
  s := edt2.Text;
  with kbmtbl1 do
  begin
    FilterOptions := [foNoPartialCompare];
    Filtered := false;
    Filter := s + #10;
    if Trim(s) <> '' then
      Filtered := True;
  end;
  ds1.DataSet := kbmtbl1;

end;

procedure TframRtcKbmHz.btn3Click(Sender: TObject);
var
  s: string;
begin
  s := edt3.Text;
  if Trim(s) = '' then
    exit;
  with kbmMemSQL1 do
  begin
    Tables.Clear;
    Tables.Add('t1', kbmtbl1);
    ExecSQL(s);
  end;
  ds1.DataSet := kbmMemSQL1;

end;

end.
